<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
	<title>统计出现次数最多的字符</title>
</head>
<body>

</body>
<script type="text/javascript">
	var str = "abcdadagaadad";
	var obj = {};
	var arr = [];
	var letter;
	for(var i=0;i<str.length;i++){
		letter = str[i];
		if( !obj[letter]){
			obj[letter] = 1;
		}else{
			obj[letter]++;
		}
	}
   var max_key;max_num = 0;
   for(key in obj) {
   	if(max_num<obj[key]) {
   		max_num = obj[key];
   		max_key = key;
   	}
   }
   document.write("字母：" + max_key + "次数：" + max_num);
</script>
</html>